import { useStore, mapGetters } from "vuex"
import { computed } from "vue"

export function useGetters(mapper) {
  const store = useStore()

  const stateFns = mapGetters(mapper)

  const state = {}

  Object.keys(stateFns).forEach((fnKey) => {
    const fn = stateFns[fnKey].bind({ $store: store })
    state[fnKey] = computed(fn)
  })

  return state
}
